package com.bluetrum.devicemanager.cmd.payloadhandler;

import androidx.annotation.NonNull;

import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
import java.util.function.BiConsumer;

public class TlvResponsePayloadHandler extends TlvPayloadHandler<Map<Byte, Boolean>> {

    public TlvResponsePayloadHandler(@NonNull byte[] payload) {
        super(payload);
    }

    @Override
    public Map<Byte, Boolean> call() throws Exception {
        final HashMap<Byte, Boolean> map = new HashMap<>();

        getTlvEntries().forEach((t, v) -> {
            // 在Response中，如果长度不为1则为格式错误，暂时不处理
            if (v.length == 1) {
                map.put(t, (v[0] == 0x00));
            }
        });

        return map;
    }

}
